<%-- 
    Document   : profiles
    Created on : Dec 10, 2011, 3:46:01 PM
    Author     : THIENSUHACK
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.LinkedList"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="GetData.DataWS"%>
<%@page import="DTO.sinhvien"%>

 <% 
 if(session.getAttribute("uid")==null)
         {
     response.sendRedirect("/DKTC/frontend/index.jsp?page=index.jsp"); 
 }
 else
         {
 if(request.getParameter("oldpass")!=null && request.getParameter("newpass")!=null)
         {
     
 dktc_ws.Sinhvien sv=new dktc_ws.Sinhvien();
 

String id=session.getAttribute("uid").toString();

request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    response.setContentType("text/html; charset=UTF-8"); 
String oldpass=request.getParameter("oldpass").trim().toString();
String newpass=request.getParameter("newpass").trim().toString(); 
 
  
//CharsetFilter ab=new CharsetFilter();
//sv.setHoten(ab.toUTF8(sv.getHoten()));
//sv.setDiachi(ab.toUTF8(sv.getDiachi()));
   int result=0;
   DataWS a=new DataWS(); 
//    Gets a calendar using the default time zone and locale.
  // out.print(id+"olpas:"+oldpass+"newpass:"+newpass);
  result=a.capnhatmatkhausinhvien(id, oldpass, newpass);
   if(result>0)
             {
      session.removeAttribute("uid"); 
    session.removeAttribute("uname"); 
    session.removeAttribute("fullname"); 
    session.removeAttribute("email"); 
    response.sendRedirect("/DKTC/frontend/index.jsp?page=index.jsp"); 
   }
 // else out.print("NOT OK");
%>

<%
 }
 } %>
<script>
   window.location="/DKTC/frontend/index2.jsp?page=profiles";
</script>